import { Body, Controller, Get, Param, Query } from '@nestjs/common';
import { AppService } from './app.service';
import { TypedBody, TypedQuery, TypedRoute } from '@nestia/core';
import { IBodyTest, IRandomQuery } from './type';

@Controller('app')
export class AppController {
  constructor(private readonly appService: AppService) {}

/**测试接口1 */
  @TypedRoute.Get("random")
  getHello(@Query() query: IRandomQuery, @Body() body: IBodyTest): IRandomQuery {
    return this.appService.getHello(query);
  }
/**测试接口2 */
  @TypedRoute.Post("test-body")
  getTest(@TypedBody() body: IBodyTest): IBodyTest {
    return this.appService.getTest(body);
  }

  @TypedRoute.Post("test-body2")
  getTest2(@Param("id") id: string,@TypedBody() body: IBodyTest): IBodyTest {
    return this.appService.getTest(body);
  }
}
